home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1989 February / Ahoy_Magazine_89-02_1989_Double_L.d64 / Monkeys & Coco (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  695b  |  28 lines

  1. 1 rem =================================
  2. 2 rem
  3. 3 rem       monkeys & coconuts
  4. 4 rem      (brute force method)
  5. 5 rem
  6. 6 rem        rupert report #62
  7. 7 rem
  8. 9 rem =================================
  9. 10 def fnii(z)=(z=int(z)) :rem true if z is integer
  10. 15 print "[147]": hm $=chr$(19) :rem home
  11. 20 for a=1 to 10000
  12. 25 print hm$; a;
  13. 30 b=(a-1)/5 :rem taken by 1st sailor
  14. 35 if not fnii(b) then 100
  15. 40 c=(a-b-2)/5 :rem 2nd sailor
  16. 45 if not fnii(c) then 100
  17. 50 d=(a-b-c-3)/5 :rem 3rd sailor
  18. 55 if not fnii(d) then 100
  19. 60 e=(a-b-c-d-4)/5 :rem 4th sailor
  20. 65 if not fnii(e) then 100
  21. 70 f=(a-b-c-d-e-5)/5 :rem 5th sailor
  22. 75 if not fnii(f) then 100
  23. 80 g=(a-b-c-d-e-f-5)/5 :rem altogether
  24. 85 if not fnii(g) then 100
  25. 90 print: print "solution: initial # coconuts =";a
  26. 100 next a
  27. 110 print
  28.